<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>修改密码</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="middle-box middle-box-register text-center loginscreen   animated fadeInDown">
        <div>
            <div>
                <h1 class="logo-name">Game</h1>
            </div>
            <h3>修改登录密码</h3>
            
        </div>
    </div>

    <div class="row" >
        <div class="col-sm-4" ></div>
                <div class="col-sm-4" >
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form class="form-horizontal m-t" id="commentForm" action="">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">旧密码：</label>
                                <div class="col-sm-6">
                                    <input id="old_password" type="password" class="form-control" name="old_password">
                                </div>
                                <span class="cred t1"></span>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">新密码：</label>
                                <div class="col-sm-6">
                                    <input id="password" type="password" class="form-control" name="password">
                                </div>
                                <span class="cred t2"></span>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-4 control-label">确认新密码：</label>
                                <div class="col-sm-6">
                                    <input id="re_password" type="password" class="form-control" name="re_password">
                                </div>
                                <span class="cred t3"></span>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-6 col-sm-offset-4">
                                    <button type="button" class="btn btn-primary block full-width m-b">确认修改</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
                
            </div>
            <div class="col-sm-4" ></div>
                
    </div>

    </div>


    <!-- 全局js -->
    <script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>

    <!-- 自定义js -->
    <script src="__PUBLIC__/admin/js/content.js?v=1.0.0"></script>

    <!-- jQuery Validation plugin javascript-->
    <script src="__PUBLIC__/admin/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="__PUBLIC__/admin/js/plugins/validate/messages_zh.min.js"></script>

    <!-- <script src="__PUBLIC__/admin/js/demo/form-validate-demo.js"></script> -->
 <script type="text/javascript">
        $(".btn-primary").click(function() {
            var old_password=$.trim($('#old_password').val());
            var password=$.trim($('#password').val());
            var re_password=$.trim($('#re_password').val());

            if (old_password=='') {
                $('.t1').html('请输入旧密码!');
                return false;
            }else{
                $('.t1').html('');
            }
            if (password=='') {
                $('.t2').html('请输入新密码!');
                return false;
            }else{
                $('.t2').html('');
            }
            if (re_password=='') {
                $('.t3').html('请确认新密码!');
                return false;
            }else{
                $('.t3').html('');
            }
            if (re_password!=password) {
                $('.t3').html('两次新密码不一致!');
                return false;
            }else{
                $('.t3').html('');
            }
            var params = {old_password:old_password,password:password};
            var url = "{:U('Admin/Admin/pwdSave')}";
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                data: params,
                success: function (data) {
                    if (data == 'error') {
                        $('.t1').html('旧密码不正确!');
                    } else if (data == 'success') {
                        alert('修改成功！');
                        window.location.href = "{:U('Admin/Login/login')}";
                    } else {
                        alert('修改失败！');
                    }
                }
            });
        });
    </script>  
    
    

</body>

</html>
